import Vue from 'vue'
import Router from 'vue-router'
import util from '@util'
// import yptFxConfig from '../localStorage/yptFxConfig'
import Login from '../components/common/Login.vue'
import WebLayout from '../components/common/WebLayout.vue'
import AlreadyPut from '../components/dropBox/AlreadyPut.vue'
import CanOrderMan from '../components/dropBox/CanOrderMan.vue'
import CouldOrderMan from '../components/dropBox/CouldOrderMan.vue'
import DropBoxHistory from '../components/dropBox/DropBoxHistory.vue'
import CompleteAndReview from '../components/dropBox/CompleteAndReview.vue'
import DropBoxMan from '../components/dropBox/DropBoxMan.vue'
import EirMan from '../components/dropBox/EirMan.vue'
import OrderStatistics from '../components/dropBox/OrderStatistics.vue'
import RevocationSummary from '../components/dropBox/RevocationSummary.vue'
import BoxagReementmain from '../components/dropBox/BoxagReementmain.vue'
import ShipGenerationDistribution from '../components/dropBox/ShipGenerationDistribution.vue'
import ImportSummary from '../components/dropBox/ImportSummary.vue'
import ImportBoxMan from '../components/importCrating/importBoxMan.vue'
import ImportedShipGenerationStatistics from '../components/importCrating/ImportedShipGenerationStatistics.vue'
// import ImportBoxManHistory from '../components/importCrating/importBoxManHistory.vue'
import AnnouncementMan from '../components/announcement/AnnouncementMan.vue'
import CompanySetting from '../components/companySetting/CompanySetting.vue'
import ReturnBox from '../components/basicInfo/ReturnBox.vue'
import ShipCompany from '../components/basicInfo/ShipCompany.vue'
import DailyCollection from '../components/finance/DailyCollection.vue'
import MonthTable from '../components/finance/MonthTable.vue'
import BusinessCollection from '../components/finance/BusinessCollection.vue'
import importReceivableStatistics from '../components/importCrating/importReceivableStatistics.vue'
import BoatFinance from '../components/finance/BoatFinance.vue'
import CostParameterConfiguration from '../components/finance/CostParameterConfiguration.vue'
import CustomerMaintenance from '../components/finance/CustomerMaintenance.vue'
import ShipMaintenance from '../components/finance/ShipMaintenance.vue'
import FinancialSettlement from '../components/finance/FinancialSettlement.vue'
import OperatorSummary from '../components/finance/OperatorSummary.vue'
import ShipSettlement from '../components/finance/ShipSettlement.vue'
import ImportCostParameter from '../components/finance/ImportCostParameter.vue'
import CustomeMan from '../components/cpInfoMan/CustomeMan.vue'
import ShipGenerationSetting from '../components/cpInfoMan/ShipGenerationSetting.vue'
import CpDataMaintain from '../components/cpInfoMan/CpDataMaintain.vue'
import BoxCompanyManagement from '../components/cpInfoMan/BoxCompanyManagement.vue'
import SalesmanMan from '../components/userMan/SalesmanMan.vue'
import DepartmentMan from '../components/userMan/DepartmentMan.vue'
import Boxermanagement from '../components/userMan/Boxermanagement.vue'
import PrevisionSearch from '../components/prevision/PrevisionSearch.vue'
import PrintTransferOrder from '../components/common/PrintTransferOrder.vue'
import CommonQuery from '../components/prevision/CommonQuery.vue'

Vue.use(Router)

const router = new Router({
  routes: [
    { // 默认
      path: '/',
      redirect: '/webLayout/dropBoxMan'
    },
    { // 登录
      path: '/login',
      name: 'Login',
      component: Login
    },
    { // 打印
      path: '/printTransferOrder',
      name: 'PrintTransferOrder',
      component: PrintTransferOrder
    },
    { // 主视图
      path: '/webLayout',
      name: 'WebLayout',
      component: WebLayout,
      children: [
        { // 出口放箱 - 出口放箱管理
          path: 'dropBoxMan',
          name: '出口放箱管理',
          component: DropBoxMan
        },
        { // 出口放箱 - 出口放箱历史记录
          path: 'dropBoxHistory',
          name: '出口放箱汇总',
          component: DropBoxHistory
        },
        { // 出口放箱 - 完成审核列表
          path: 'completeAndReview',
          name: '完成审核列表',
          component: CompleteAndReview
        },
        { // 出口放箱 - 已放好客户
          path: 'alreadyPut',
          name: '已放好客户',
          component: AlreadyPut
        },
        { // 出口放箱 - 电子EIR管理
          path: 'eirMan',
          name: '电子EIR管理',
          component: EirMan
        },
        { // 出口放箱 - 可打单管理
          path: 'canOrderMan',
          name: '可打单管理',
          component: CanOrderMan
        },
        { // 出口放箱 - 已打单管理
          path: 'couldOrderMan',
          name: '已打单管理',
          component: CouldOrderMan
        },
        { // 出口放箱 - 打单统计
          path: 'orderStatistics',
          name: '打单统计',
          component: OrderStatistics
        },
        { // 出口放箱 - 撤销汇总
          path: 'revocationSummary',
          name: '撤销汇总',
          component: RevocationSummary
        },
        { // 出口放箱 - 放箱协议维护
          path: 'boxagReementmain',
          name: '放箱协议维护',
          component: BoxagReementmain
        },
        { // 出口放箱 - 船代操作分配
          path: 'shipGenerationDistribution',
          name: '船代操作分配',
          component: ShipGenerationDistribution
        },
        { // 出口放箱 - 进口应收统计
          path: 'importReceivableStatistics',
          name: '进口应收统计',
          component: importReceivableStatistics
        },
        { // 进口放箱管理
          path: 'importBoxMan',
          name: '进口放箱管理',
          component: ImportBoxMan
        },
        // {
        //   path: 'importBoxManHistory',
        //   name: '进口放箱汇总',
        //   component: ImportBoxManHistory
        // },
        { // 进口撤销汇总
          path: 'importSummary',
          name: '进口撤销汇总',
          component: ImportSummary
        },
        { // 进口船代统计
          path: 'importedShipGenerationStatistics',
          name: '进口船代统计',
          component: ImportedShipGenerationStatistics
        },
        { // 公告管理 - 公告管理
          path: 'announcementMan',
          name: '公告管理',
          component: AnnouncementMan
        },
        { // 公司设置 - 公司设置
          path: 'companySetting',
          name: '公司设置',
          component: CompanySetting
        },
        { // 基础信息 - 提还箱点
          path: 'returnBox',
          name: '提还箱点',
          component: ReturnBox
        },
        { // 基础信息 - 船代公司
          path: 'shipCompany',
          name: '船代公司',
          component: ShipCompany
        },
        { // 财务统计 - 进口费用参数配置
          path: 'importCostParameter',
          name: '进口费用参数配置',
          component: ImportCostParameter
        },
        { // 财务统计 - 日汇总表
          path: 'dailyCollection',
          name: '日汇总表',
          component: DailyCollection
        },
        { // 财务统计 - 月统计表
          path: 'monthTable',
          name: '月统计表',
          component: MonthTable
        },
        { // 财务统计 - 业务汇总表
          path: 'businessCollection',
          name: '业务汇总表',
          component: BusinessCollection
        },
        { // 财务统计 - 费用参数配置
          path: 'costParameterConfiguration',
          name: '费用参数配置',
          component: CostParameterConfiguration
        },
        { // 财务统计 - 船代财务
          path: 'boatFinance',
          name: '船代财务',
          component: BoatFinance
        },
        { // 财务统计 - 客户打款维护
          path: 'customerMaintenance',
          name: '客户打款维护',
          component: CustomerMaintenance
        },
        { // 财务统计 - 船代付款维护
          path: 'shipMaintenance',
          name: '船代付款维护',
          component: ShipMaintenance
        },
        { // 财务统计 - 财务结算
          path: 'financialSettlement',
          name: '财务结算',
          component: FinancialSettlement
        },
        { // 财务统计 - 操作员汇总
          path: 'operatorSummary',
          name: '操作员汇总',
          component: OperatorSummary
        },
        { // 财务统计 - 船代结算
          path: 'shipSettlement',
          name: '船代结算',
          component: ShipSettlement
        },
        { // 公司信息管理 - 客户管理
          path: 'customeMan',
          name: '客户管理',
          component: CustomeMan
        },
        { // 公司信息管理 - 公司资料维护
          path: 'cpDataMaintain',
          name: '公司资料维护',
          component: CpDataMaintain
        },
        { // 公司信息管理 - 放箱公司管理
          path: 'boxCompanyManagement',
          name: '放箱公司管理',
          component: BoxCompanyManagement
        },
        { // 公司信息管理 - 船代设置
          path: 'shipGenerationSetting',
          name: '船代设置',
          component: ShipGenerationSetting
        },
        { // 用户管理 - 业务员管理
          path: 'salesmanMan',
          name: '业务员管理',
          component: SalesmanMan
        },
        { // 用户管理 - 部门管理
          path: 'departmentMan',
          name: '部门管理',
          component: DepartmentMan
        },
        { // 用户管理 - 放箱员管理
          path: 'boxermanagement',
          name: '放箱员管理',
          component: Boxermanagement
        },
        { // 预配查询 - 预配查询
          path: 'previsionSearch',
          name: '预配查询',
          component: PrevisionSearch
        },
        { // 预配查询 - 常用查询
          path: 'commonQuery',
          name: '常用查询',
          component: CommonQuery
        }
      ]
    }
  ]
})

// router.beforeEach((to, from, next) => {
//   if (!yptFxConfig.getStorage()) {
//     yptFxConfig.createStorage({
//       putBoxManageComId: '4f4dd6ba-f9ee-41b7-9052-b1ca81ac7b0c',
//       salesmanId: '54a54455-d1e7-43b6-abbf-3aa0b00ef50f'
//     })
//   }
//   router.app.$store.state.web.breadcrumb = to.name
//   next()
// })
router.beforeEach((to, from, next) => {
  if (to.path !== '/login' && !util.getItem('$user_fx')) {
    next({path: '/login'})
  } else {
    next()
  }
})

export default router
